/**
 * Copyright (c) 2010 SKRATCHDOT.COM
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Initial modeling finished using information provided by:
 * 	http://www.sonicspot.com/guide/wavefiles.html
 * 
 * Contributors:
 *     JEFF |:at:| SKRATCHDOT |:dot:| COM
 *
 * $Id$
 */
package com.skratchdot.riff.wav.provider;

import com.skratchdot.riff.wav.util.WavAdapterFactory;

import java.util.ArrayList;
import java.util.Collection;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;

import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;

/**
 * This is the factory that is used to provide the interfaces needed to support Viewers.
 * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
 * The adapters also support Eclipse property sheets.
 * Note that most of the adapters are shared among multiple instances.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class WavItemProviderAdapterFactory extends WavAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
	/**
	 * This keeps track of the root adapter factory that delegates to this adapter factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComposedAdapterFactory parentAdapterFactory;

	/**
	 * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IChangeNotifier changeNotifier = new ChangeNotifier();

	/**
	 * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Collection<Object> supportedTypes = new ArrayList<Object>();

	/**
	 * This constructs an instance.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public WavItemProviderAdapterFactory() {
		supportedTypes.add(IEditingDomainItemProvider.class);
		supportedTypes.add(IStructuredItemContentProvider.class);
		supportedTypes.add(ITreeItemContentProvider.class);
		supportedTypes.add(IItemLabelProvider.class);
		supportedTypes.add(IItemPropertySource.class);
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.RIFFWave} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RIFFWaveItemProvider riffWaveItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.RIFFWave}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createRIFFWaveAdapter() {
		if (riffWaveItemProvider == null) {
			riffWaveItemProvider = new RIFFWaveItemProvider(this);
		}

		return riffWaveItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.Channel} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChannelItemProvider channelItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.Channel}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createChannelAdapter() {
		if (channelItemProvider == null) {
			channelItemProvider = new ChannelItemProvider(this);
		}

		return channelItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.ChunkCue} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChunkCueItemProvider chunkCueItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.ChunkCue}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createChunkCueAdapter() {
		if (chunkCueItemProvider == null) {
			chunkCueItemProvider = new ChunkCueItemProvider(this);
		}

		return chunkCueItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.ChunkData} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChunkDataItemProvider chunkDataItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.ChunkData}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createChunkDataAdapter() {
		if (chunkDataItemProvider == null) {
			chunkDataItemProvider = new ChunkDataItemProvider(this);
		}

		return chunkDataItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.ChunkDataList} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChunkDataListItemProvider chunkDataListItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.ChunkDataList}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createChunkDataListAdapter() {
		if (chunkDataListItemProvider == null) {
			chunkDataListItemProvider = new ChunkDataListItemProvider(this);
		}

		return chunkDataListItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.ChunkDataListTypeLabel} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChunkDataListTypeLabelItemProvider chunkDataListTypeLabelItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.ChunkDataListTypeLabel}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createChunkDataListTypeLabelAdapter() {
		if (chunkDataListTypeLabelItemProvider == null) {
			chunkDataListTypeLabelItemProvider = new ChunkDataListTypeLabelItemProvider(this);
		}

		return chunkDataListTypeLabelItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.ChunkDataListTypeLabeledText} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChunkDataListTypeLabeledTextItemProvider chunkDataListTypeLabeledTextItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.ChunkDataListTypeLabeledText}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createChunkDataListTypeLabeledTextAdapter() {
		if (chunkDataListTypeLabeledTextItemProvider == null) {
			chunkDataListTypeLabeledTextItemProvider = new ChunkDataListTypeLabeledTextItemProvider(this);
		}

		return chunkDataListTypeLabeledTextItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.ChunkDataListTypeNote} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChunkDataListTypeNoteItemProvider chunkDataListTypeNoteItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.ChunkDataListTypeNote}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createChunkDataListTypeNoteAdapter() {
		if (chunkDataListTypeNoteItemProvider == null) {
			chunkDataListTypeNoteItemProvider = new ChunkDataListTypeNoteItemProvider(this);
		}

		return chunkDataListTypeNoteItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.ChunkFact} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChunkFactItemProvider chunkFactItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.ChunkFact}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createChunkFactAdapter() {
		if (chunkFactItemProvider == null) {
			chunkFactItemProvider = new ChunkFactItemProvider(this);
		}

		return chunkFactItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.ChunkFormat} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChunkFormatItemProvider chunkFormatItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.ChunkFormat}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createChunkFormatAdapter() {
		if (chunkFormatItemProvider == null) {
			chunkFormatItemProvider = new ChunkFormatItemProvider(this);
		}

		return chunkFormatItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.ChunkInstrument} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChunkInstrumentItemProvider chunkInstrumentItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.ChunkInstrument}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createChunkInstrumentAdapter() {
		if (chunkInstrumentItemProvider == null) {
			chunkInstrumentItemProvider = new ChunkInstrumentItemProvider(this);
		}

		return chunkInstrumentItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.ChunkPlayList} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChunkPlayListItemProvider chunkPlayListItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.ChunkPlayList}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createChunkPlayListAdapter() {
		if (chunkPlayListItemProvider == null) {
			chunkPlayListItemProvider = new ChunkPlayListItemProvider(this);
		}

		return chunkPlayListItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.ChunkSampler} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChunkSamplerItemProvider chunkSamplerItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.ChunkSampler}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createChunkSamplerAdapter() {
		if (chunkSamplerItemProvider == null) {
			chunkSamplerItemProvider = new ChunkSamplerItemProvider(this);
		}

		return chunkSamplerItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.ChunkSilent} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChunkSilentItemProvider chunkSilentItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.ChunkSilent}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createChunkSilentAdapter() {
		if (chunkSilentItemProvider == null) {
			chunkSilentItemProvider = new ChunkSilentItemProvider(this);
		}

		return chunkSilentItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.ChunkUnknown} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChunkUnknownItemProvider chunkUnknownItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.ChunkUnknown}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createChunkUnknownAdapter() {
		if (chunkUnknownItemProvider == null) {
			chunkUnknownItemProvider = new ChunkUnknownItemProvider(this);
		}

		return chunkUnknownItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.ChunkWaveList} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChunkWaveListItemProvider chunkWaveListItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.ChunkWaveList}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createChunkWaveListAdapter() {
		if (chunkWaveListItemProvider == null) {
			chunkWaveListItemProvider = new ChunkWaveListItemProvider(this);
		}

		return chunkWaveListItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.CuePoint} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CuePointItemProvider cuePointItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.CuePoint}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createCuePointAdapter() {
		if (cuePointItemProvider == null) {
			cuePointItemProvider = new CuePointItemProvider(this);
		}

		return cuePointItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.ParseChunkException} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ParseChunkExceptionItemProvider parseChunkExceptionItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.ParseChunkException}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createParseChunkExceptionAdapter() {
		if (parseChunkExceptionItemProvider == null) {
			parseChunkExceptionItemProvider = new ParseChunkExceptionItemProvider(this);
		}

		return parseChunkExceptionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.SampleData8Bit} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SampleData8BitItemProvider sampleData8BitItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.SampleData8Bit}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSampleData8BitAdapter() {
		if (sampleData8BitItemProvider == null) {
			sampleData8BitItemProvider = new SampleData8BitItemProvider(this);
		}

		return sampleData8BitItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.SampleData16Bit} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SampleData16BitItemProvider sampleData16BitItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.SampleData16Bit}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSampleData16BitAdapter() {
		if (sampleData16BitItemProvider == null) {
			sampleData16BitItemProvider = new SampleData16BitItemProvider(this);
		}

		return sampleData16BitItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.SampleLoop} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SampleLoopItemProvider sampleLoopItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.SampleLoop}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSampleLoopAdapter() {
		if (sampleLoopItemProvider == null) {
			sampleLoopItemProvider = new SampleLoopItemProvider(this);
		}

		return sampleLoopItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.skratchdot.riff.wav.Segment} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SegmentItemProvider segmentItemProvider;

	/**
	 * This creates an adapter for a {@link com.skratchdot.riff.wav.Segment}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSegmentAdapter() {
		if (segmentItemProvider == null) {
			segmentItemProvider = new SegmentItemProvider(this);
		}

		return segmentItemProvider;
	}

	/**
	 * This returns the root adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComposeableAdapterFactory getRootAdapterFactory() {
		return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
	}

	/**
	 * This sets the composed adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
		this.parentAdapterFactory = parentAdapterFactory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean isFactoryForType(Object type) {
		return supportedTypes.contains(type) || super.isFactoryForType(type);
	}

	/**
	 * This implementation substitutes the factory itself as the key for the adapter.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter adapt(Notifier notifier, Object type) {
		return super.adapt(notifier, this);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object adapt(Object object, Object type) {
		if (isFactoryForType(type)) {
			Object adapter = super.adapt(object, type);
			if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) {
				return adapter;
			}
		}

		return null;
	}

	/**
	 * This adds a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void addListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.addListener(notifyChangedListener);
	}

	/**
	 * This removes a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void removeListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.removeListener(notifyChangedListener);
	}

	/**
	 * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void fireNotifyChanged(Notification notification) {
		changeNotifier.fireNotifyChanged(notification);

		if (parentAdapterFactory != null) {
			parentAdapterFactory.fireNotifyChanged(notification);
		}
	}

	/**
	 * This disposes all of the item providers created by this factory. 
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void dispose() {
		if (riffWaveItemProvider != null) riffWaveItemProvider.dispose();
		if (channelItemProvider != null) channelItemProvider.dispose();
		if (chunkCueItemProvider != null) chunkCueItemProvider.dispose();
		if (chunkDataItemProvider != null) chunkDataItemProvider.dispose();
		if (chunkDataListItemProvider != null) chunkDataListItemProvider.dispose();
		if (chunkDataListTypeLabelItemProvider != null) chunkDataListTypeLabelItemProvider.dispose();
		if (chunkDataListTypeLabeledTextItemProvider != null) chunkDataListTypeLabeledTextItemProvider.dispose();
		if (chunkDataListTypeNoteItemProvider != null) chunkDataListTypeNoteItemProvider.dispose();
		if (chunkFactItemProvider != null) chunkFactItemProvider.dispose();
		if (chunkFormatItemProvider != null) chunkFormatItemProvider.dispose();
		if (chunkInstrumentItemProvider != null) chunkInstrumentItemProvider.dispose();
		if (chunkPlayListItemProvider != null) chunkPlayListItemProvider.dispose();
		if (chunkSamplerItemProvider != null) chunkSamplerItemProvider.dispose();
		if (chunkSilentItemProvider != null) chunkSilentItemProvider.dispose();
		if (chunkUnknownItemProvider != null) chunkUnknownItemProvider.dispose();
		if (chunkWaveListItemProvider != null) chunkWaveListItemProvider.dispose();
		if (cuePointItemProvider != null) cuePointItemProvider.dispose();
		if (parseChunkExceptionItemProvider != null) parseChunkExceptionItemProvider.dispose();
		if (sampleData8BitItemProvider != null) sampleData8BitItemProvider.dispose();
		if (sampleData16BitItemProvider != null) sampleData16BitItemProvider.dispose();
		if (sampleLoopItemProvider != null) sampleLoopItemProvider.dispose();
		if (segmentItemProvider != null) segmentItemProvider.dispose();
	}

}
